import { Injectable } from '@angular/core';
import { GlobalVars } from '../providers/globalVars';

@Injectable()
export class PermissionService {
    private _permissions: any;

    constructor(
        private globalVars: GlobalVars
    ) {}

    hasPermission(permissionName: string) {
        var hasPermiss = false;
        this._permissions = this.globalVars.getMyGlobalVar('permissions');
        if (this._permissions && this._permissions.length > 0) {
            this._permissions.forEach(function (permission) {
                if (permissionName == permission) {
                    hasPermiss = true;
                }
            });
        }
        return hasPermiss;
    }
}